<?php include('./templete/public/head.php')?>
<script src="_js/plug/rili.js"></script>
<body>
<div class="sing-in-main">
    <div class="sing-in-content">
        <!--sing-in-top-->
<!--        <div class="sing-in-top">-->
<!--            <div class="top1">-->
<!--                <span>0</span>-->
<!--                <span>0</span>-->
<!--                <span id="sign-count">0</span> 天-->
<!--            </div>-->
<!--            <div class="top2">-->
<!--                漏签--><?php //echo ceil($lq)?><!--天-->
<!--            </div>-->
<!--            <div class="sing-btn" id='signIn'>-->
<!--                <a id="sign-txt">签到</a>-->
<!--            </div>-->
<!--        </div>-->
        <!--sing-in-top-->
        <div class="sing-in-top">
            <div class="top1">
                <div class="div1 center">
                    <div class="div2 center">
                        <div class="sing-btn" id='signIn'>
                            <p class="p1"><strong id="sign-txt">签到</strong></p>
                            <p class="line"></p>
                            <p class="p2">本月已签到<span id="sign-count"><?php echo $thissign['count']?></span>天</p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="top2">
                漏签<?php echo $lq_day?>天
            </div>
            <!--<div class="sing-btn" id='signIn'>
                <a id="sign-txt">签到</a>
            </div>-->
        </div>
        <!--sing-in-bot-->
        <div class="sing-in-bot">
            <div class="Calendar">
                <div id="toyear">
                    <div id="idCalendarPre">&lt;</div>
                    <div class="year-month">
                        <span id="idCalendarYear">2018</span>年<span id="idCalendarMonth">6</span>月
                    </div>
                    <div id="idCalendarNext">&gt;</div>
                </div>
                <table border="1px" cellpadding="0" cellspacing="0">
                    <thead>
                    <tr class="tou">
                        <td>日</td>
                        <td>一</td>
                        <td>二</td>
                        <td>三</td>
                        <td>四</td>
                        <td>五</td>
                        <td>六</td>
                    </tr>
                    </thead>
                    <tbody id="idCalendar">
                    </tbody>
                </table>
            </div>

        </div>
    </div>
</div>
</body>

<script>
    var isSign = false;

    var myday =<?php echo json_encode($list)?>; //已签到的数组


    var cale = new Calendar("idCalendar", {
        qdDay: myday,
        onToday: function(o) {
            o.className = "onToday";
        },
        onSignIn: function() {
            $$("sign-txt").innerHTML = '已签到';
        },
        onFinish: function() {
            //$$("sign-count").innerHTML = myday.length //已签到次数
            $$("idCalendarYear").innerHTML = this.Year;
            $$("idCalendarMonth").innerHTML = this.Month; //表头年份

        }
    });
    $$("idCalendarPre").onclick = function() {
        cale.PreMonth();
    }
    $$("idCalendarNext").onclick = function() {
        cale.NextMonth();
    }
    //添加今天签到
    $$("signIn").onclick = function() {
        $.ajax({
            url:"<?php echo url('to_sign')?>",
            success:function (data) {
                if(data.code==1){
                    if(isSign == false) {
                        var res = cale.SignIn();
                        if(res == '1') {
                            $$("sign-txt").innerHTML = '已签到';
                            $$("sign-count").innerHTML = parseInt($$("sign-count").innerHTML) + 1;
                            isSign = true;

                        } else if(res == '2') {
                            $$("sign-txt").innerHTML = '已签到';
                            mui.toast('今天已经签到了');
                        }
                    } else {
                        mui.toast('今天已经签到了');
                    }
                }else{
                    $$("sign-txt").innerHTML = '已签到';
                    mui.toast('今天已经签到了');
                }
            }
        });
    }
</script>

</html>